# pip install tencentcloud-sdk-python
from tencentcloud.sms.v20210111 import sms_client, models
from tencentcloud.common import credential
from libs.conn import *

def send_sms_tencent(phone_number, template_id, sign_name, params):
    # 腾讯云的 SecretId 和 SecretKey
    sign_name = get_config('sms_tencent_sign_name')
    secret_id = get_config('sms_tencent_secret_key')
    secret_key = get_config('sms_tencent_secret_key')
    template_id = get_config('sms_tencent_template_id')
    
    cred = credential.Credential(secret_id, secret_key)
    client = sms_client.SmsClient(cred, "ap-guangzhou")
    
    # 创建请求
    req = models.SendSmsRequest()
    req.PhoneNumberSet = [phone_number]
    req.TemplateID = template_id
    req.SignName = sign_name
    req.TemplateParamSet = params
    
    # 发送请求
    resp = client.SendSms(req)
    
    # 返回响应
    return resp.to_json_string()

if __name__ == "__main__":
    # 调用发送短信函数
    response = send_sms_tencent(
        phone_number="+1234567890",
        template_id="your_template_id",
        sign_name="your_sms_sign_name",
        params=["123456"]
    )
    print(response)
